package org.genesilico.workflow2.graphs.tests;

import java.util.Arrays;
import java.util.Random;

import org.genesilico.workflow2.graphs.GraphNode;
import org.genesilico.workflow2.graphs.Node;
import org.genesilico.workflow2.graphs.isomorphism.PermutationsGenerator;
import org.junit.Test;


public class GraphNodePermutationTest {
	/**
	 * Creates a graph and randomly permutes it. The output is visualised on the
	 * console.
	 */
	@Test
	public void graphNodePermutations() {
		Random rnd = new Random();
		final int SIZE = 10;
		GraphNode[] g1 = new GraphNode[SIZE];
		for (int i = 0; i < SIZE; i++) {
			g1[i] = new GraphNode(i, new Node(Integer.toString(rnd.nextInt())),
					new int[] { i - 1 }, new int[] { i + 1 });
		}
		g1[0].parents = new int[] {};
		g1[SIZE - 1].children = new int[] {};

		System.out.println(Arrays.toString(g1));
		for (int i = 0; i < 100; i++) {
			GraphNode[] g2 = PermutationsGenerator.permuteGraphNodes(g1);
			System.out.println(Arrays.toString(g2));
		}
	}
}
